__author__ = 'v-yuezh'
import sys
import re

from PyQt5.QtWidgets import  QApplication
from PyQt5.QtCore import QUrl
from PyQt5.QtWebKitWidgets import QWebView


class Browser(QWebView):

    def __init__(self):
        QWebView.__init__(self)
        self.loadFinished.connect(self.__result_available)

    def __result_available(self, ok):
        frame = self.page().mainFrame()
        dom = frame.toHtml()
        parse(dom)

def parse(dom):
    #print(dom)
    html = str(dom)
    imglist = re.findall('/article/.*?\d{6}">(.*?)</a>',html)
    #imglist = re.findall('shtml.*?>(.*?)</a>',html)
    for x in imglist:
        print(x)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    view = Browser()
    url = "http://www.newsmth.net/nForum/#!board/Career_Campus"
    view.load(QUrl(url))
    app.exec()
